<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="css/beiyong.css" />
		<title></title>
		<style type="text/css">
			img{
				max-width: 100%;
				height: auto;
			}
		</style>
	</head>
	<body>
		<div class="mui-content">
			<!--
            	作者：592176224@qq.com
            	时间：2019-01-15
            	描述：
		    <input type="" name="" id="" value="" />
            -->
			<img src="images/101.jpg"/>
			<img id="img2" src=""/>
		    <button type="button" class="mui-btn mui-btn-blue" onclick="getbase64()">设置</button>
		</div>
		
		
		
		<script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/mui.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/req.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/muishow.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			console.log(acctoken());
			//63558199ebd85b9c2058ef14d8815a8c
			
			function subbase64(){
                	
                		let data = {
                		url:'/api/Image/upload',
                		data:{
                			access_token:acctoken(),
                			image:"11"
                		}
                	}
                	ajaxbase64(data,function(res){
                		console.log(res);
                		console.log("上传base64成功");
                		let data = {
							url:"/api/Personal/update_member",
							data:{
								access_token : acctoken()||"",
								nickname : "",
								introduction : "",
								mid :res.data[0].mid
							}
						}
						ajax(data,function(res1){
							mui.hideLoading();
	                        console.log(res1);
	                        if(res1.code == 1){
	                        	mui.toast("修改成功！");
	                        	getname();
	                        }
	                        if(res1.code == -1){
	                        	mui.toast(res1.message);
	                        }
						})
                		
                		
                	})
                	
				
				
			}
			function getbase64(){
				var img = "images/101.jpg";
				  getBase64Image(img,function(res){
                		console.log(res.dataURL);
                		console.log(res.dataURL.length);
                		
                		g("img2").src = res.dataURL;
                	upladbase64(res.dataURL,function(res2){
                		console.log(res2);
                		console.log("上传base64成功");
                		let data = {
							url:"/api/Personal/update_member",
							data:{
								access_token : acctoken()||"",
								nickname : "",
								introduction : "",
								mid :res2.data[0].mid
							}
						}
						ajax(data,function(res1){
							mui.hideLoading();
	                        console.log(res1);
	                        if(res1.code == 1){
	                        	mui.toast("修改成功！");
	                        	getname();
	                        }
	                        if(res1.code == -1){
	                        	mui.toast(res1.message);
	                        }
						})
                		
                		
                	})
                })
			}
			
			  
			function upladbase64(base64, func) {
				let xhr = null,
					url = hurl + '/api/Image/uploadBase64',
					form = new FormData();
				form.append("base64", base64); // 文件对象
				form.append("access_token", acctoken()); // 可以增加表单数据
				xhr = new XMLHttpRequest(); // XMLHttpRequest 对象
				xhr.open("post", url, true); //post方式，url为服务器请求地址，true 该参数规定请求是否异步处理。
				xhr.onload = function(evt) {
					var data = JSON.parse(evt.target.responseText);
					func(data);
				}
				xhr.onerror = function(err) { //请求失败 
					console.log(err);
					mui.toast("文件上传失败");
				}; 
				xhr.send(form); //开始上传，发送form数据
			}
			
		</script>
	</body>
</html>
